﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BloggerImageConversion
{
    public partial class GoogleLogin : Form
    {
        private Google.GData.Client.Service service;
        public string token;

        public string User
        {
            get
            {
                return txtUsername.Text;
            }
        }

        public GoogleLogin()
        {
            InitializeComponent();
        }

        public GoogleLogin(Google.GData.Client.Service service)
            : this()
        {
            this.service = service;
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            string user = txtUsername.Text;
            string password = txtPassword.Text;


            service.setUserCredentials(user, password);

   
            try
            {
                token = service.QueryClientLoginToken();
                service.SetAuthenticationToken(token);
            }
            catch (Exception ex)
            {
                
            }

            if (String.IsNullOrWhiteSpace(token))
            {
                MessageBox.Show("Login incorrect.");

            }
            else
            {
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }

        }

        private void ultraButton1_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }
    }
}
